﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:userControls="clr-namespace:VH.UI.UserControls;assembly=VH.UI.UserControls"
                    xmlns:resources="clr-namespace:VH.Resources;assembly=VH.Resources" 
                    xmlns:view="clr-namespace:VH.View">
    <Style TargetType="{x:Type userControls:ModalDailogWindow}">
        <Setter Property="FontSize" Value="{StaticResource ContentFontSize}"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Visibility" Value="Visible" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="AllowDrop" Value="False" />
      <Setter Property="WindowState" Value="Normal" />
        <Setter Property="ShowMinimizeButton" Value="True" />
        <Setter Property="ShowMaximizeButton" Value="True" />
        <Setter Property="ShowCloseButton" Value="True" />
      <Setter Property="IsActive" Value="{Binding IsActive}" />
        <Setter Property="ViewMode" Value="{Binding ViewMode}" />
        <!--<Setter Property="Title" Value="Sample Window" />-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type userControls:ModalDailogWindow}">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="WindowState">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Minimized">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Maximized">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" Storyboard.TargetName="MaximizeButtonLabel">
                                            <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="2"/>
                                        </StringAnimationUsingKeyFrames>
                                        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="ToolTip" Storyboard.TargetName="PART_MaximizeButton">
                                            <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="Restore"/>
                                        </StringAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" 
                                Effect="{StaticResource DropShadowBrush}"/>

                        
                        <Grid Margin="20,16,20,5">
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="RowHeader" Height="Auto" />
                                <RowDefinition Height="20"/>
                                <RowDefinition x:Name="RowBody" Height="*" />
                                <RowDefinition x:Name="RowFooter" Height="Auto" />
                            </Grid.RowDefinitions>
                                               
                            <Grid Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <Rectangle x:Name="PART_Dragger"
                                           Grid.Column="0" Grid.ColumnSpan="2"
                                           Margin="3.5"
                                           Fill="Transparent" />
                                
                                <Grid Grid.Column="0"
                                      IsHitTestVisible="False"
                                      HorizontalAlignment="Left" VerticalAlignment="Center" Margin="3.5">
                                
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="15" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <ProgressBar x:Name="BrandBar" Grid.Row="0" 
                                                 Minimum="0" Maximum="100"
                                                 Foreground="{StaticResource AccentColorBlueBrush}"
                                                 HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                                                 Width="250" Height="6" IsHitTestVisible="False" 
                                                 Value="100" />
                                                                        
                                    <TextBlock Grid.Row="1"
                                               FontFamily="{StaticResource HeaderFontFamily}" FontSize="{StaticResource HeaderFontSize}" FontWeight="SemiBold"
                                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                                               HorizontalAlignment="Left" VerticalAlignment="Center" 
                                               IsHitTestVisible="False" />
                                </Grid>

                                <Grid Grid.Column="1"
                                      HorizontalAlignment="Right" VerticalAlignment="Center" Margin="3.5">
                                    
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <Button x:Name="PART_MinimizeButton" Grid.Column="0"
                                            Style="{StaticResource MetroButtonStyle}"
                                            Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MinimizeCommand}"
                                            VerticalAlignment="Center" Margin="1.5"
                                            ToolTip="Minimize">
                                        <TextBlock x:Name="MinimizeButtonLabel" TextWrapping="Wrap" Text="0" FontFamily="Webdings" FontSize="13.333" Foreground="{StaticResource TextBrush}" FontWeight="Normal" />
                                    </Button>

                                    <Button x:Name="PART_MaximizeButton" Grid.Column="1"
                                            Style="{StaticResource MetroButtonStyle}"
                                            FontFamily="Webdings" Foreground="#FF919191" FontSize="13.333" FontWeight="Normal"
                                            Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MaximizeCommand}"
                                            VerticalAlignment="Center" Margin="1.5"
                                            ToolTip="Maximize">
                                        <TextBlock x:Name="MaximizeButtonLabel" TextWrapping="Wrap" Text="1" FontFamily="Webdings" FontSize="13.333" Foreground="{StaticResource TextBrush}" FontWeight="Normal" />
                                    </Button>

                                    <Button x:Name="PART_CloseButton" Grid.Column="2"
                                            Style="{StaticResource MetroButtonStyle}"
                                            FontFamily="Webdings" Foreground="#FF919191" FontSize="13.333" FontWeight="Normal"
                                            Command="{Binding RelativeSource={RelativeSource TemplatedParent},  Path=CloseCommand}"
                                            VerticalAlignment="Center" Margin="1.5"
                                            ToolTip="Close">
                                        <TextBlock x:Name="CloseButtonLabel" TextWrapping="Wrap" Text="r" FontFamily="Webdings" FontSize="13.333" Foreground="{StaticResource TextBrush}" FontWeight="Normal" />
                                    </Button>
                                </Grid>
                            </Grid>
                            
                            <!--<chronos:HeaderNotification Grid.Row="1" Panel.ZIndex="99"
                                                        MessageText="{Binding NotificationMessage}"
                                                        VerticalAlignment="Top" />-->
                            
                            <Grid Grid.Row="2">
                                <ContentPresenter x:Name="PART_ContentPresenter"
                                                  IsEnabled="{TemplateBinding IsActive}"
                                                  Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                </ContentPresenter>
                            </Grid>

                            <Grid Grid.Row="3">
                                <TextBlock x:Name="StatusMessage" 
                                           Margin="3.5" 
                                           VerticalAlignment="Center" HorizontalAlignment="Stretch"
                                           FontFamily="{StaticResource MixedContentFontFamily}"
                                           FontSize="{StaticResource ContentFontSize}"
                                           Foreground="{StaticResource AccentColorRedBrush}"
                                           Text="{Binding Content.StatusMessage, ElementName=PART_ContentPresenter}" ToolTip="{Binding StatusMessage}" />
                            </Grid>

                            <Rectangle 
                x:Name="ModelOverlay"
                Grid.RowSpan="4" 
                Opacity="0.1"
                    Visibility="Collapsed"
                Fill="{StaticResource AccentColorLightBlueBrush}" />
                        </Grid>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="BrandBar" Property="Foreground" Value="{StaticResource AccentColorRedBrush}" />
                        </Trigger>

                        <Trigger Property="ViewMode" Value="Busy">
                            <Setter TargetName="BrandBar" Property="IsIndeterminate" Value="True" />
                        </Trigger>

                        <Trigger Property="ShowMinimizeButton" Value="False">
                            <Setter TargetName="PART_MinimizeButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <Trigger Property="ShowMaximizeButton" Value="False">
                            <Setter TargetName="PART_MaximizeButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <Trigger Property="ShowCloseButton" Value="False">
                            <Setter TargetName="PART_CloseButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type userControls:MessageWindowElement}">
        <!--<Setter Property="FocusVisualStyle" Value="{x:Null}" />-->
        <Setter Property="Background" Value="{StaticResource GradientBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="WindowState" Value="Normal" />
        <Setter Property="Visibility" Value="Visible" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="AllowDrop" Value="False" />
        <Setter Property="Title" Value="Sample Window" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type userControls:MessageWindowElement}">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></BooleanToVisibilityConverter>
                        </Grid.Resources>

                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" 
                                Effect="{StaticResource DropShadowBrush}"/>

                        <Grid Margin="30,16,30,30">
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="RowHeader" Height="Auto" />
                                <RowDefinition Height="5" />
                                <RowDefinition x:Name="RowBody" Height="*" />
                                <RowDefinition x:Name="RowFooter" Height="Auto" />
                            </Grid.RowDefinitions>

                            <Grid Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <Rectangle x:Name="PART_Dragger"
                                           Grid.Column="0" Grid.ColumnSpan="2"
                                           Margin="3.5"
                                           Fill="Transparent" />

                                <Grid Grid.Column="0"
                                      IsHitTestVisible="False"
                                      HorizontalAlignment="Left" VerticalAlignment="Center" Margin="3.5">

                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="15" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <Rectangle Grid.Row="0"
                                               VerticalAlignment="Bottom" HorizontalAlignment="Left"
                                               Fill="{StaticResource AccentColorBlueBrush}" 
                                               Width="109" Height="6"
                                               IsHitTestVisible="False" />

                                    <TextBlock Grid.Row="1"
                                               FontFamily="{StaticResource HeaderFontFamily}" FontSize="{StaticResource HeaderFontSize}" FontWeight="SemiBold"
                                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                                               HorizontalAlignment="Left" VerticalAlignment="Center" 
                                               IsHitTestVisible="False" />
                                </Grid>
                            </Grid>

                            <Grid Grid.Row="2">
                                <ContentControl FontSize="{StaticResource ContentFontSize}" FontWeight="SemiBold">
                                    <!--<ContentPresenter x:Name="PART_ContentPresenter"
                                                        Content="{TemplateBinding Content}"
                                                        ContentTemplate="{TemplateBinding ContentTemplate}"
                                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    </ContentPresenter>-->
                                    <ScrollViewer BorderThickness="0" Background="Transparent">
                                    <TextBlock 
                                        x:Name="PART_ContentPresenter"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                                        Text="{TemplateBinding Content}"
                                        TextWrapping="WrapWithOverflow"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    </TextBlock>
                                        </ScrollViewer>
                                </ContentControl>
                            </Grid>

                            <Grid Grid.Row="3">
                                <StackPanel x:Name="ButtonsPanel"
                                            Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">

                                    <Button x:Name="AcceptButton" 
                                            Style="{StaticResource HyperlinkButtonStyle}"
                                            Margin="3.5" Padding="2"
                                            Command="userControls:MessageWindowElement.AcceptCommand" IsDefault="True" />

                                    <Button x:Name="CancelButton" 
                                            Margin="3.5" Padding="2"
                                            Style="{StaticResource HyperlinkButtonStyle}"
                                            Command="userControls:MessageWindowElement.CancelCommand" IsCancel="True" />

                                </StackPanel>
                            </Grid>
                        </Grid>

                        <Border BorderBrush="{DynamicResource WindowBorderActive}" BorderThickness="1" Visibility="{Binding IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Buttons" Value="YesNo">
                            <Setter TargetName="AcceptButton" Property="Content" Value="{x:Static resources:ButtonResources.Accept}" />
                            <Setter TargetName="CancelButton" Property="Content" Value="{x:Static resources:ButtonResources.Cancel}" />
                        </Trigger>
                        <Trigger Property="Buttons" Value="OKCancel">
                            <Setter TargetName="AcceptButton" Property="Content" Value="{x:Static resources:ButtonResources.Ok}" />
                            <Setter TargetName="CancelButton" Property="Content" Value="{x:Static resources:ButtonResources.Cancel}" />
                        </Trigger>
                        <Trigger Property="Buttons" Value="Ok">
                            <Setter TargetName="ButtonsPanel" Property="HorizontalAlignment" Value="Center" />
                            <Setter TargetName="AcceptButton" Property="Content" Value="{x:Static resources:ButtonResources.Ok}" />
                            <Setter TargetName="CancelButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>